/**
 * Copyright (C) 2009+ Spark Zheng
 *
 * @file        src/config.h 
 * @date        2010-04-05
 * @brief	server_framework
 * @see         dserver
 * @history
 */

#ifndef _DSERVER_CONFIG_H
#define _DSERVER_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

#include <dlib/global.h>

#include "dserver.h"
#include "dserver_log.h"
#include "dserver_errno.h"

#define BASE_DIR	"/home/zhengyu/Projects/mfs_projects/dserver"
#define CONF_DIR	BASE_DIR"/conf"
#define LOG_DIR		BASE_DIR"/log"
#define TEMP_DIR	"/tmp"
#define DEF_CONF_FILE	CONF_DIR"/dserver.conf"
#define DEF_PID_FILE	LOG_DIR"/dserver.pid"

#define MAIN_FIELD	"main"
#define M_MAX_FDS	"max_fds"
#define V_DEF_MAX_FDS	1024
#define M_MAX_CONNS	"max_connections"
#define V_DEF_MAX_CONNS	1024

#define M_RT_RX_BUF	"rx_buf"
#define V_DEF_RX_BUF	16384
#define M_RT_TX_BUF	"tx_buf"
#define V_DEF_TX_BUF	16384

#define M_USER		"user"
#define V_DEF_USER	"zhengyu"
#define M_GROUP		"group"
#define V_DEF_GROUP	"zhengyu"

#define M_PID_FILE	"pid_file"
#define M_LOG_PATH	"log_path"
#define M_PROTOCOLS	"protocols"
#define V_DEF_PROTOCOLS	"def_tcp, def_udp"
#define M_PROTOCOLS_DIR	"protocols_dir"
#define M_FILTERS	"filters"
#define V_DEF_FILTERS	"test_1, test_2, test_3"
#define M_FILTERS_DIR	"filters_dir"

#define MONT_FIELD	"monitor"
#define T_HOST		"mont_host"
#define V_DEF_MHOST	"127.0.0.1"
#define T_PORT		"mont_port"
#define V_DEF_MPORT	10010
#define T_TIMEOUT	"mont_timeout"
#define V_DEF_MTIMEOUT	30
#define T_PRIORITY	"mont_priority"
#define V_DEF_PRIORITY	5

/**
 * main_conf_init
 * @brief read the conf file and fill into settings, return 0 or err.
 * @param s: running arguments 
 */
extern int main_conf_init(dserver_setting_t *s);

/** 
 * main_conf_exit
 * @brief release the memory in settings
 * @param s: running arguments
 */
extern void main_conf_exit(dserver_setting_t *s);

/**
 * set_main_conf_file
 * @brief set the config files into settings
 * @param f: file path from commandline argument
 * @param s: running arguments
 */
extern void set_main_conf_file(const char *f, dserver_setting_t *s);

#ifdef __cplusplus
}
#endif
#endif
